_require local "../../basis.smi"
_require "../../thread.smi"
_require local "./ForeachCommon.smi"

structure ForeachData =
struct

  eqtype index (= int)
  val rootIndex : index
  structure Thread =
  struct
    type thread = Myth.thread
    val create : (unit -> index) -> thread
    val join : thread -> index
  end

  type 'a context =
      {
        value : index -> 'a,
        newValue : index -> 'a,
        size : int
      }

  val ForeachData
      : ['seq, 'para.
        {
          initialize : ('seq -> index) -> 'seq -> 'para,
          finalize : (index -> 'seq) -> 'para -> 'seq
        }
        -> 'seq
        -> (index * 'para context -> 'para)
        -> (index * 'para context -> bool)
        -> 'seq
        ]

end
